#ifndef QUERYHISTORYDIALOG_H
#define QUERYHISTORYDIALOG_H

#include <QDialog>
#include <QList>
#include <QDateTime>
#include "queryhistorymanager.h"

class QTreeWidget;
class QPushButton;
class QLineEdit;
class QDialogButtonBox;

class QueryHistoryDialog : public QDialog
{
    Q_OBJECT

public:
    explicit QueryHistoryDialog(QueryHistoryManager *manager, QWidget *parent = nullptr);
    
signals:
    void querySelected(const QString &query);

private slots:
    void loadHistory();
    void searchHistory();
    void onItemDoubleClicked();
    void onItemSelected();
    void clearHistory();
    void useSelectedQuery();

private:
    void setupUI();
    void updateHistoryList(const QList<QueryHistoryItem> &items);
    
    QueryHistoryManager *m_historyManager;
    QTreeWidget *m_historyTree;
    QPushButton *m_useButton;
    QPushButton *m_clearButton;
    QLineEdit *m_searchEdit;
    QDialogButtonBox *m_buttonBox;
    
    QString m_selectedQuery;
};

#endif // QUERYHISTORYDIALOG_H